<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>会员充值</title>
    <link rel="stylesheet" type="text/css" href="css/amazeui.min.css"/>
    <link rel="stylesheet" type="text/css" href="css/main.css"/>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/amazeui.min.js"></script>
    <script type="text/javascript" src="/js/ui-choose.js"></script>
</head>
<body>
<div class="pay">
    <!--主内容开始编辑-->
    <div class="tr_recharge">
        <div class="tr_rechtext">
            <p class="te_retit"><img src="/img/coin.png" alt=""/>充值中心</p>
        </div>
        <form action="/recharge" method="post" class="am-form" id="doc-vld-msg">
            <div class="tr_rechbox">
                <div class="tr_rechhead">
                    <img src="/img/ys_head2.jpg"/>
                    <p>会员卡号：
                        <label class="am-radio-inline">
                            <input type="text" value="" name="cardNumber" required data-validation-message="请输入会员卡号">
                        </label>
                    </p>
                </div>
                <div class="tr_rechli am-form-group">
                    <ul class="ui-choose am-form-group" id="uc_01">
                        <li>
                            <label class="am-radio-inline">
                                <input type="radio" value="1" name="type" required
                                       data-validation-message="请选择一项充值额度"> 100￥/月
                            </label>
                        </li>
                        <li>
                            <label class="am-radio-inline">
                                <input type="radio" value="2" name="type" data-validation-message="请选择一项充值额度"> 280￥/季
                            </label>
                        </li>

                        <li>
                            <label class="am-radio-inline">
                                <input type="radio" value="3" name="type" data-validation-message="请选择一项充值额度"> 1100￥/年
                            </label>
                        </li>
                    </ul>
                    <!--<span>1招兵币=1元 10元起充</span>-->
                </div>
                <div class="tr_rechoth am-form-group">
                    <span>其他金额：</span>
                    <input type="number" min="10" max="10000" value="10.00元" class="othbox"
                           data-validation-message="充值金额范围：10-10000元"/>
                    <!--<p>充值金额范围：10-10000元</p>-->
                </div>
                <div class="tr_rechnum">
                    <span>应付金额：</span>
                    <p class="rechnum">0.00元</p>
                </div>
            </div>
            <div class="tr_paybox">
                <input type="submit" value="确认支付" class="tr_pay am-btn"/>
            </div>
        </form>
    </div>
</div>


<script type="text/javascript">
    // 将所有.ui-choose实例化
    $('.ui-choose').ui_choose();
    // uc_01 ul 单选
    let uc_01 = $('#uc_01').data('ui-choose'); // 取回已实例化的对象
    uc_01.click = function (index, item) {
        console.log('click', index, item.text())
    }
    uc_01.change = function (index, item) {
        console.log('change', index, item.text())
    }
    $(function () {
        $('#uc_01 li:eq(3)').click(function () {
            $('.tr_rechoth').show();
            $('.tr_rechoth').find("input").attr('required', 'true')
            $('.rechnum').text('100.00元');
        })
        $('#uc_01 li:eq(0)').click(function () {
            $('.tr_rechoth').hide();
            $('.rechnum').text('100.00元');
            $('.othbox').val('');
        })
        $('#uc_01 li:eq(1)').click(function () {
            $('.tr_rechoth').hide();
            $('.rechnum').text('280.00元');
            $('.othbox').val('');
        })
        $('#uc_01 li:eq(2)').click(function () {
            $('.tr_rechoth').hide();
            $('.rechnum').text('1100.00元');
            $('.othbox').val('');
        })
        $(document).ready(function () {
            $('.othbox').on('input propertychange', function () {
                let num = $(this).val();
                $('.rechnum').html(num + ".00元");
            });
        });
    })

    $(function () {
        $('#doc-vld-msg').validator({
            onValid: function (validity) {
                $(validity.field).closest('.am-form-group').find('.am-alert').hide();
            },
            onInValid: function (validity) {
                let $field = $(validity.field);
                let $group = $field.closest('.am-form-group');
                let $alert = $group.find('.am-alert');
                // 使用自定义的提示信息 或 插件内置的提示信息
                let msg = $field.data('validationMessage') || this.getValidationMessage(validity);

                if (!$alert.length) {
                    $alert = $('<div class="am-alert am-alert-danger"></div>').hide().appendTo($group);
                }
                $alert.html(msg).show();
            }
        });
    });
</script>

</body>
</html>